package com.gobang.domain.enums;

/**
 * 游戏状态枚举
 * 
 * @author System
 * @since 1.0.0
 */
public enum GameStatus {
    
    /**
     * 等待中
     */
    WAITING("WAITING", "等待中"),
    
    /**
     * 游戏中
     */
    PLAYING("PLAYING", "游戏中"),
    
    /**
     * 已结束
     */
    FINISHED("FINISHED", "已结束"),
    
    /**
     * 已取消
     */
    CANCELLED("CANCELLED", "已取消");
    
    private final String code;
    private final String description;
    
    GameStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    public String getCode() {
        return code;
    }
    
    public String getDescription() {
        return description;
    }
    
    /**
     * 根据状态码获取枚举
     *
     * @param code 状态码
     * @return 游戏状态枚举
     */
    public static GameStatus fromCode(String code) {
        for (GameStatus status : GameStatus.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的游戏状态码: " + code);
    }
} 